<%@ page import="question.ClassifyInfo" %>
<%@ page import="com.opensymphony.xwork2.util.ValueStack" %>
<%@ page import="java.util.List" %>
<%@ page import="utils.TextUtils" %>
<%@ page import="java.util.Map" %>
<%@ page import="setup.SetupInfo" %>
<%@ page import="setup.KmSettingInfo" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
  <title></title>
  <link href="../../skin/default/global.css" rel="stylesheet" type="text/css"/>
  <link href="../../skin/default/layout.css" rel="stylesheet" type="text/css"/>
  <style>
    html, body {
      overflow-x: hidden
    }
  </style>
</head>
<%
  ValueStack vs = (ValueStack) request.getAttribute("struts.valueStack");
  int kmID = (Integer) vs.findValue("kmID");
  KmSettingInfo settingInfo = (KmSettingInfo) vs.findValue("kmSettingInfo");
  List<ClassifyInfo> dtList = (List<ClassifyInfo>) vs.findValue("dtList");
  Map<Integer, List<ClassifyInfo>> ydMap = (Map<Integer, List<ClassifyInfo>>) vs.findValue("ydMap");
  Map<Integer, SetupInfo> staMap = (Map<Integer, SetupInfo>) vs.findValue("staMap");
  Map<Integer, SetupInfo> setMap = (Map<Integer, SetupInfo>) vs.findValue("setMap");
%>
<body class="admin-content admin-panel-body" style="overflow:hidden">
<form action="setup.action" method="post">
<input id="avalue" value="<%=settingInfo.getSValue()%>" type="hidden"/><!--单选-->
<input id="bvalue" value="<%=settingInfo.getMValue()%>" type="hidden"/><!--多选-->
<input id="cvalue" value="<%=settingInfo.getTValue()%>" type="hidden"/><!--判断-->
<table cellpadding="0" cellspacing="0" height="100%" width="100%">
<thead>
  <tr>
    <td style="height:30px;">
      <div id="noticepop">

        <div style="float:left; padding:10px;">
          <span>考试时间：<strong id="timebox"><%=settingInfo.getExamTime()%></strong> 分钟</span>
					<span>通过分值：<strong id="passbox"><%=settingInfo.getPassScore()%></strong> 分
					<span>
					 单选题<strong id="sbox"><%=settingInfo.getSValue()%></strong>分/题，多选题<strong id="mbox"><%=settingInfo.getMValue()%></strong>分/题，判断题<strong id="tbox"><%=settingInfo.getTValue()%></strong>分/题。
					</span>
					<br/>
					
					<div style="padding:5px 0; color:#CC3300">已选择 单选题<strong id="abox">24</strong>题， 多选题
            <strong id="bbox">24</strong>题， 判断题<strong id="cbox">24</strong>题 。 共<strong id="ebox">0</strong>题，<strong id="dbox">60</strong>分
          </div>
        </div>

        <div class="admin-tablenav" style="float:right;">
          <button type="button" onClick="kswindow.open({title:'考试设定',url:'querySetting.action?kmID=<%=kmID%>',width:'300'})" class="normal blue">
            <span></span>考试设定
          </button>
          <button type="submit" class="normal blue">
            <span></span>保存修改
          </button>
        </div>

        <div style="clear:both"></div>
      </div>
    </td>
  </tr>
</thead>

<tbody>
<tr>
<td>
<div style="height:100%; overflow:auto; border:1px solid #ccc; background:#fff;wdth:100%">
<input type="hidden" name="kmID" value="<%=kmID%>"/>

<table cellpadding="0" cellspacing="0" class="admin-table" style="margin:0;">
  <thead>
    <tr>
      <th style="width:30px"><span class="first"></span>编码</th>
      <th style="width:120px">考试项目</th>

      <th>考试要点</th>
      <th style="width:150px">题型分配</th>
      <th style="width:40px;" class="last">分值</th>
    </tr>
  </thead>
  <tbody id="rightslist">
    <%
      int index = 0;
      for (ClassifyInfo dt : dtList) {
        List<ClassifyInfo> ydList = ydMap.get(dt.getCid());
        for (ClassifyInfo yd : ydList) {
          SetupInfo staSetup = staMap.get(yd.getCid());
          SetupInfo setSetup = setMap.get(yd.getCid());
    %>
    <tr>
      <td class="first"><%=++index%>
      </td>
      <td><%=TextUtils.html(dt.getCname())%>&nbsp;</td>
      <td><%=TextUtils.html(yd.getCname())%>&nbsp;</td>
      <td class="setting">
        <%
          if (staSetup.getSSum() != 0) {
        %>
        <div class="tlist">单选题：<span><%=(staSetup.getSSum()<10?" ":"")+staSetup.getSSum()%></span>题<input onKeyPress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" name="s_<%=yd.getCid()%>" class="numInput a" value="<%=setSetup==null?0:setSetup.getSSum()%>" style="width:30px; height:21px; border:1px solid #999; font-size:13px;padding:2px;"/></div>
        <%
          }
          if (staSetup.getMSum() != 0) {
        %>
        <div class="tlist">多选题：<span><%=(staSetup.getMSum()<10?" ":"")+staSetup.getMSum()%></span>题<input onKeyPress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" name="m_<%=yd.getCid()%>" class="numInput b" value="<%=setSetup==null?0:setSetup.getMSum()%>" style="width:30px; height:21px; border:1px solid #999; font-size:13px;padding:2px;"/></div>
        <%
          }
          if (staSetup.getTSum() != 0) {
        %>
        <div class="tlist">判断题：<span><%=(staSetup.getTSum()<10?" ":"")+staSetup.getTSum()%></span>题<input onKeyPress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" name="t_<%=yd.getCid()%>" class="numInput c" value="<%=setSetup==null?0:setSetup.getTSum()%>" style="width:30px; height:21px; border:1px solid #999; font-size:13px;padding:2px;"/></div>
        <%
          }
        %>
      </td>
      <td class="last">

        <span style="font-size:18px; text-align:center; font-weight:bold">0</span>

        <!--<input onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" name="yd_<%=yd.getCid()%>" class="numInput" value="" style="width:80%; height:20px; border:1px solid #999; font-size:16px;padding:3px;"/>-->
      </td>
    </tr>
    <%
        }
      }
    %>
  </tbody>
  <!--<tfoot>
       <tr>
         <td colspan="10" style="padding-right:15px" class="last"><span class="first"></span>
         总分：100
         </td>
       </tr>
     </tfoot>-->
</table>



</div>
</td>
</tr>
</tbody>
</table>
</form>
<iframe name="execute" id="execute" src="" width="0" height="0"></iframe>

<script src="../../common/jquery-1.3.2.min.js"></script>
<script src="../../common/jquery.blockUI.js"></script>
<script src="../../common/fun.js"></script>
<script>
$(function() {
  checkNum()
  kswindow = new KS.Window();
})
var list = new KS.List("rightslist")
$("#rightslist tr").find("input").focus(function() {
  $(this).select()
}).blur(function() {
  if($(this).val()>parseFloat($(this).parent().find("span").html())){
  	alert("所选题量不能超过已有题量，请重新输入")
  	$(this).select();
  	return false;
  }
  else{
  checkNum()
  }
})


function resetValue(){
	
	
	var passValue_ = $("#passScore").val();
	var timeValue_ = $("#examTime").val();
		
	var sValue_ = $("#sValue").val();
	var mValue_ = $("#mValue").val();
	var tValue_ = $("#tValue").val();
	
	$("#passbox").html(passValue_)
	$("#timebox").html(timeValue_)
	$("#sbox").html(sValue_)
	$("#mbox").html(mValue_)
	$("#tbox").html(tValue_)
	
	
	$("#avalue").val(sValue_);
  	$("#bvalue").val(mValue_);
  	$("#cvalue").val(tValue_);
	
	checkNum()
	kswindow.close()
}

function checkNum() {

  var _a = 0;
  var _b = 0;
  var _c = 0;

  var _all = 100;
  var _last = 0;

  var a = $(".a")
  var b = $(".b")
  var c = $(".c")


  var abox_ = $("#abox");
  var bbox_ = $("#bbox");
  var cbox_ = $("#cbox");
  var dbox_ = $("#dbox");
  var ebox_ = $("#ebox");

  var avalue_ = $("#avalue").val();
  var bvalue_ = $("#bvalue").val();
  var cvalue_ = $("#cvalue").val();

  var allsettingTD = $("td.setting")

  a.each(function(i) {
  	var $aval = $(this).val()
    if (IsNum($aval)) {
      _a += parseInt($aval)
    }
  })
  b.each(function(i) {
  	var $bval = $(this).val()
    if (IsNum($bval)) {
      _b += parseInt($bval)
    }
  })
  c.each(function(i) {
  	var $cval = $(this).val()
    if (IsNum($cval)) {
      _c += parseInt($cval)
    }
  })

  allsettingTD.each(function(i) {
    var inputchild = $(this).find(".numInput")
    var thistdValue = 0;
    inputchild.each(function(j) {
		 var $this = $(this)
		 var $thisvalue = $this.val()
      if ($this.hasClass("a")) {

        thistdValue += parseInt($thisvalue * avalue_)

      }

      else if ($this.hasClass("b")) {

        thistdValue += parseInt($thisvalue * bvalue_)

      }
      else if ($this.hasClass("c")) {

        thistdValue += parseInt($thisvalue * cvalue_)

      }

    })

     $(this).next().find("span").html(thistdValue)

  })

  abox_.html(_a)
  bbox_.html(_b)
  cbox_.html(_c)
  dbox_.html(_a * avalue_ + _b * bvalue_ + _c * cvalue_)
  ebox_.html(_a+_b+_c)

}

function IsNum(s)
{
  if (s != null && s != "")
  {
    return !isNaN(s);
  }
  return false;
}

</script>

<!--<div id="pop">剩余分值：50 分</div>-->

</body>

</html>
